#include "Test.Box.h"

#undef  APP_NAME
#define APP_NAME	TestTrigger
#undef  APP_BASE
#define APP_BASE	TestBoxPhysics


class APP_NAME : public APP_BASE
{
protected:
	Trigger			trigger;
	const vec2		triggerSize;

public:
	APP_NAME (IPlatform *platform, EDevice::type deviceType) :
		APP_BASE( platform, deviceType ),
		triggerSize(0.3f)
	{}
	

	void Update (float dt) override
	{
		TestPhysicsApp::Update( dt );
		
		ESS()->GetGraphicsEngine()->GetViewport()->Apply();
		ESS()->GetGLStateManager()->ClearColor( color4f( 0.0f ) );


		// process physics
		world.Update( dt );
		
		Draw();
		
		ESS()->GetGraphicsEngine()->GetRender2D().DrawRect( material, trigger.GetPosition(),
			triggerSize * 2.0f, color4u::Default::Yellow(), false, false );

		batch.Flush();
		batch.Clear();
		
		ESS()->GetGraphicsEngine()->SwapBuffers();
	}


	void OnEnter () override
	{
		APP_BASE::OnEnter();

		trigger.Create( world.GetWorld() );
		ShapeUtils::AddBox( trigger, triggerSize );
	}
};